/*
* 数据链追溯
*/
isc.defineClass("EMESR_DataLinkTracing", isc.OBBaseView).addProperties({
	width: '100%',
	height: '100%',
	align: 'center',
	defaultLayoutAlign: 'center',
	keyDown:function(event){
		if(event.nativeKeyCode==13){
			queryForm.search();
			return false;
		}
		return true;
	},
	allItem : [],
	orderId: null,
	submit: function(isForce){
		alert("提交代码未写！");
	},
	clearForm: function(){
		this.orderId = null;
		//this.demandForm.hide();
		this.planOrderForm.hide();
		this.planOrderGrid.hide();
		this.planOrderGridTitle.hide();
		this.manuOrderForm.hide();
		this.manuOrderGrid.hide();
		this.manuOrderGridTitle.hide();
		//this.jobPlanForm.hide();
		//this.jobPlanGrid.hide();
		//this.jobPlanGridTitle.hide();
		this.jobOrderForm.hide();
		this.jobOrderGrid.hide();
		this.jobOrderGridTitle.hide();
		this.planOrderOutForm.hide(); 
		
		//this.clearValue(this.demandForm);
		this.clearValue(this.planOrderForm);
		this.clearValue(this.manuOrderForm);
		//this.clearValue(this.jobPlanForm);
		this.clearValue(this.jobOrderForm);
		this.clearValue(this.planOrderOutForm);
		
	},
	clearValue: function(form) {
		var itemIds = form.getField("group").itemIds;
		for(var i = 0 ; i < itemIds.length; i ++){
			var name = itemIds[i];
			if(form.getField(name)){
				form.clearValue(name);
			}
		}
	},
	initWidget: function () {
		var _self = this;
		//OB控件 追加	addField or addItem	会有样式和事件找不到的问题
		
		this.queryForm = isc.DynamicForm.create({
			ID: "queryForm",
			numCols : 6,
			width: 900,
			search: function(){
				var orderCode = queryForm.getValue("orderCode");
				var orderType = queryForm.getValue("orderType");
				if(orderCode == ''){
					isc.showMessage("请输入编码", isc.OBMessageBar.TYPE_INFO);
					return;
				}
				_self.clearForm();
				_self.serchData(orderCode, orderType);
			},
			fields : [
				{width: "*", type: 'select', title: '编码所属列别', name: 'orderType' , value: '生产订单', valueMap: [
					"计划订单", "生产订单", "作业订单","外协订单"
				], startRow: true},
				{width: "*",type: 'text', title: '编码', name: 'orderCode' ,value:'',startRow: false},
				{width: "*",type: 'button',title:'查&nbsp;&nbsp;询', name: 'btnSearch', startRow: false,
					click: function(){queryForm.search();}, showIf: "true"
				}
			]
		});
		
		//this.createDemandPanel();
		this.createPlanOrderPanel();
		this.createManuOrderPanel();
		//this.createJobPlanPanel();
		this.createJobOrderPanel();
		this.createPlanOrderOut()
		
		this.addMember(isc.VLayout.create({
			width: '100%',
			layoutMargin : 15,
			membersMargin : 10,
			members : [
				this.queryForm,
				//this.demandForm,
				this.planOrderForm,
				this.planOrderGrid,
				this.planOrderGridTitle,
				this.manuOrderForm,
				this.manuOrderGrid,
				this.manuOrderGridTitle,
				//this.jobPlanForm,
				//this.jobPlanGrid,
				//this.jobPlanGridTitle,
				this.jobOrderForm,
				this.jobOrderGrid,
				this.jobOrderGridTitle,
				this.planOrderOutForm
			]
		}));
		this.clearForm();
		this.Super("initWidget", arguments);
	},
	createDemandPanel: function() {
		var _self = this;
		this.demandForm = isc.DynamicForm.create({
			ID: "demandForm",
			numCols: 8,
			width: 1000,
			fields : [
				{width: "*", name:'group', type: 'OBSectionItem',defaultValue: '需求计划信息', itemIds: [
					"code", "name", "reqDate", "qty", "topProduct", "product", "saleno", 'status'
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '编码', name: 'code'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '名称', name: 'name'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求日期', name: 'reqDate'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '所属产品', name: 'topProduct'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '生产产品', name: 'product'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '销售订单号', name: 'saleno'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '状态', name: 'status'}
			]
		});
	},
	createPlanOrderPanel: function() {
		var _self = this;
		this.planOrderForm = isc.DynamicForm.create({
			ID: "planOrderForm",
			numCols: 8,
			width: 1000,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '计划订单信息', itemIds: [
					"code", "name", "qtyDone", "qty", "executeDateFrom", "executeDateTo", "topProduct", "product", "saleno", 'status'
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '编码', name: 'code'}, 
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '名称', name: 'name'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工数量', name: 'qtyDone'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '开工日期', name: 'executeDateFrom'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工日期', name: 'executeDateTo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '所属产品', name: 'topProduct'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '生产产品', name: 'product'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '销售订单号', name: 'saleno'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '状态', name: 'status'}
			]
		});
		this.planOrderGridTitle = isc.DynamicForm.create({
			ID: "planOrderGridTitle",
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '计划订单列表', itemIds: [
					"planOrderGrid"
				], startRow: true}
			]
		});
		this.planOrderGrid = isc.ListGrid.create({
			title: "计划订单",
			ID: "planOrderGrid",
			height: 200,
			//dataSource: rbCountryTransactions, //远程数据库连接数据源
			autoFetchData: true,
			canEdit: true,
			autoSaveEdits: true,
			fields: [
				{title: "编号", name: "code", canEdit: false},
				{title: "名称", name: "name", canEdit: false},
				{title: '需求数量', name: 'qty', canEdit: false},
				{title: '完工数量', name: 'qtyDone', canEdit: false},
				{title: '开工日期', name: 'executeDateFrom', canEdit: false},
				{title: '完工日期', name: 'executeDateTo', canEdit: false},
				{title: '所属产品', name: 'topProduct', canEdit: false},
				{title: '生产产品', name: 'product', canEdit: false},
				{title: '销售订单号', name: 'saleno', canEdit: false},
				{title: '状态', name: 'status', canEdit: false}
			], //对应的字段
			//data: countryData, //数据来源
			alternateRecordStyles: true,
			canEdit: true,
			canDragRecordsOut: true,
			canAcceptDroppedRecords: true,
			canReorderRecords: true,
			canReorderFields: true,
			canResizeFields: true,
			recordClick: function(grid, data, index) {
				_self.manuOrderGrid.hide();
				//_self.jobPlanGrid.hide();
				_self.jobOrderGrid.hide();
				_self.serchData(data.id, "manuOrderList");
			}
		});
	},
	createManuOrderPanel: function() {
		var _self = this;
		this.manuOrderForm = isc.DynamicForm.create({
			ID: "manuOrderForm",
			width: 1000,
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '生产订单信息', itemIds: [
					"code", "name", "qtyDone", "qty", "qtyStarted", "topProduct", "product", "batchNo", "seqNo", "manuorderStatus","departmentname"
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '编码', name: 'code'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '名称', name: 'name'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '开工数量', name: 'qtyStarted'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工数量', name: 'qtyDone'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '所属产品', name: 'topProduct'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '生产产品', name: 'product'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '批次号', name: 'batchNo'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '序列号', name: 'seqNo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '订单状态', name: 'manuorderStatus'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '责任部门', name: 'departmentname'}
			]
		});
		this.manuOrderGridTitle = isc.DynamicForm.create({
			ID: "manuOrderGridTitle",
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '生产订单列表', itemIds: [
					"manuOrderGrid"
				], startRow: true}
			]
		});
		this.manuOrderGrid = isc.ListGrid.create({
			title: "生产订单",
			ID: "manuOrderGrid",
			height: 200,
			//dataSource: rbCountryTransactions, //远程数据库连接数据源
			autoFetchData: true,
			canEdit: true,
			autoSaveEdits: true,
			fields: [
				{canEdit: false, title: '编码', name: 'code'},
				{canEdit: false, title: '名称', name: 'name'},
				{canEdit: false, title: '需求数量', name: 'qty'},
				{canEdit: false, title: '开工数量', name: 'qtyStarted'},
				{canEdit: false, title: '完工数量', name: 'qtyDone'},
				{canEdit: false, title: '所属产品', name: 'topProduct'},
				{canEdit: false, title: '生产产品', name: 'product'},
				//{canEdit: false, title: '批次号', name: 'batchNo'},
				//{canEdit: false, title: '序列号', name: 'seqNo'},
				{canEdit: false, title: '订单状态', name: 'manuorderStatus'},
				{canEdit: false, title: '责任部门', name: 'departmentname'}
			], //对应的字段
			//data: countryData, //数据来源
			alternateRecordStyles: true,
			canEdit: true,
			canDragRecordsOut: true,
			canAcceptDroppedRecords: true,
			canReorderRecords: true,
			canReorderFields: true,
			canResizeFields: true,
			recordClick: function(grid, data, index) {
				//_self.jobPlanGrid.hide();
				_self.jobOrderGrid.hide();
				//_self.serchData(data.id, "jobPlanList");
				_self.serchData(data.id, "jobOrderList");
			}
		});
	},
	//作业计划
	createJobPlanPanel: function() {
		var _self = this;
		this.jobPlanForm = isc.DynamicForm.create({
			ID: "jobPlanForm",
			numCols: 8,
			width: 1000,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '作业计划信息', itemIds: [
					"code", "qtyDone", "qty", "qtyPlaned", "resourceGroup", "resource", "emesStation", "batchNo", "seqNo", 
					"qtyGood", "qtyError", "routeName", "exeDateFrom", "exeDateTo", "jobStatus", "department","userName"
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '编码', name: 'code'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '开工日期', name: 'exeDateFrom'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工日期', name: 'exeDateTo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '派工数量', name: 'qtyPlaned'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工数量', name: 'qtyDone'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '合格数量', name: 'qtyGood'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '不合格数量', name: 'qtyError'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '责任部门', name: 'department'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '资源组', name: 'resourceGroup'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '资源', name: 'resource'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '工序', name: 'routeName'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '批次号', name: 'batchNo'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '序列号', name: 'seqNo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '状态', name: 'jobStatus'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '操作人', name: 'userName'}
			]
		});
		this.jobPlanGridTitle = isc.DynamicForm.create({
			ID: "jobPlanGridTitle",
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '作业计划列表', itemIds: [
					"jobPlanGrid"
				], startRow: true}
			]
		});
		this.jobPlanGrid = isc.ListGrid.create({
			title: "作业计划",
			showHeaderContextMenu: true,
			ID: "jobPlanGrid",
			height: 200,
			//dataSource: rbCountryTransactions, //远程数据库连接数据源
			autoFetchData: true,
			canEdit: true,
			autoSaveEdits: true,
			fields: [
				{canEdit: false, title: '编码', name: 'code'},
				{canEdit: false, title: '需求数量', name: 'qty'},
				{canEdit: false, title: '开工日期', name: 'exeDateFrom'},
				{canEdit: false, title: '完工日期', name: 'exeDateTo'},
				{canEdit: false, title: '派工数量', name: 'qtyPlaned'},
				{canEdit: false, title: '完工数量', name: 'qtyDone'},
				//{canEdit: false, title: '合格数量', name: 'qtyGood'},
				//{canEdit: false, title: '不合格数量', name: 'qtyError'},
				//{canEdit: false, title: '责任部门', name: 'department'},
				//{canEdit: false, title: '资源组', name: 'resourceGroup'},
				//{canEdit: false, title: '资源', name: 'resource'},
				{canEdit: false, title: '工序', name: 'routeName'},
				//{canEdit: false, title: '批次号', name: 'batchNo'},
				//{canEdit: false, title: '序列号', name: 'seqNo'},
				{canEdit: false, title: '状态', name: 'jobStatus'},
				{canEdit: false, title: '操作人', name: 'userName'}
			], //对应的字段
			//data: countryData, //数据来源
			alternateRecordStyles: true,
			canEdit: true,
			canDragRecordsOut: true,
			canAcceptDroppedRecords: true,
			canReorderRecords: true,
			canReorderFields: true,
			canResizeFields: true,
			recordClick: function(grid, data, index) {
				_self.jobOrderGrid.hide();
				_self.serchData(data.id, "jobOrderList");
			}
		});
	},
	createJobOrderPanel: function() {
		this.jobOrderForm = isc.DynamicForm.create({
			ID: "jobOrderForm",
			numCols: 8,
			width: 1000,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '作业订单信息', itemIds: [
					"code", "qtyDone", "qty", "qtyStart", "resourceGroup", "resource", "emesStation", "batchNo", "seqNo", 
					"qtyGood", "qtyError", "routeName", "exeDateFrom", "exeDateTo", "jobStatus", "department","userName"
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '编码', name: 'code'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '开工日期', name: 'exeDateFrom'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工日期', name: 'exeDateTo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '开工数量', name: 'qtyStart'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '完工数量', name: 'qtyDone'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '合格数量', name: 'qtyGood'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '不合格数量', name: 'qtyError'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '责任部门', name: 'department'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '资源组', name: 'resourceGroup'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '资源', name: 'resource'},
				//{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '生产工位', name: 'emesStation'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '工序', name: 'routeName'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '状态', name: 'jobStatus'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '操作人', name: 'userName'}
			]
		});
		this.jobOrderGridTitle = isc.DynamicForm.create({
			ID: "jobOrderGridTitle",
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '作业订单列表', itemIds: ["jobOrderGrid"], startRow: true}
			]
		});
		this.jobOrderGrid = isc.ListGrid.create({
			title: "作业订单",
			ID: "jobOrderGrid",
			height: 200,
			//dataSource: rbCountryTransactions, //远程数据库连接数据源
			autoFetchData: true,
			canEdit: true,
			autoSaveEdits: true,
			fields: [
				{width: 150, title: '编码', name: 'code', canEdit: false},
				{title: '需求数量', name: 'qty', canEdit: false},
				{title: '开工数量', name: 'qtyStart', canEdit: false},
				{title: '完工数量', name: 'qtyDone', canEdit: false},
				//{title: '合格数量', name: 'qtyGood', canEdit: false},
				//{title: '不合格数量', name: 'qtyError', canEdit: false},
				//{title: '责任部门', name: 'department', canEdit: false},
				//{title: '资源组', name: 'resourceGroup', canEdit: false},
				//{title: '资源', name: 'resource', canEdit: false},
				//{title: '生产工位', name: 'emesStation', canEdit: false},
				{title: '工序', name: 'routeName', canEdit: false},
				{title: '开工日期', name: 'exeDateFrom', canEdit: false},
				{title: '完工日期', name: 'exeDateTo', canEdit: false},
				{title: '状态', name: 'jobStatus', canEdit: false},
				{title: '操作人', name: 'userName', canEdit: false}
				
			], //对应的字段
			//data: countryData, //数据来源
			alternateRecordStyles: true,
			canEdit: true,
			canDragRecordsOut: true,
			canAcceptDroppedRecords: true,
			canReorderRecords: true,
			canReorderFields: true,
			canResizeFields: true
		});
	},
	createPlanOrderOut: function() {
		this.planOrderOutForm = isc.DynamicForm.create({
			ID: "planOrderOutForm",
			numCols: 8,
			fields : [
				{width: "*", name: 'group', type: 'OBSectionItem', defaultValue: '外协计划订单', itemIds: [
					"code", "qty", "planedDateFrom", "planedDateTo", "EmespPlanorder", "product", "names", 
					"name", "Emes_Vendor", "status", "jobStatus"
				], startRow: true},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: true, title: '编码', name: 'code'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '需求数量', name: 'qty'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '下发日期', name: 'planedDateFrom'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '入库日期', name: 'planedDateTo'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '生产令号', name: 'EmespPlanorder'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '物料编码', name: 'product'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '图号', name: 'names'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '物料名称', name: 'name'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '外协供应商', name: 'Emes_Vendor'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '检验结果', name: 'status'},
				{width: "*", type: 'text', readOnlyDisplay: "static", canEdit: false, startRow: false, title: '状态', name: 'jobStatus'}
			]
		});
	},
	serchData: function(orderCode, orderType) {
		var _self = this;
		var requestData = {orderType: orderType, orderCode: orderCode};
		OB.RemoteCallManager.call("com.mes.handler.report.DataLinkTracingHandler", requestData, {}, function(response, data, request){
			if (!data.success) {
				isc.showMessage(data.msg, isc.OBMessageBar.TYPE_INFO);
				return;
			}
			if(data.demandPlan){
				//_self.setValue(data.demandPlan, _self.demandForm);
			}
			if(data.planOrder) {
				_self.setValue(data.planOrder, _self.planOrderForm);
			}
			if(data.planOrderList) {
				_self.setGridValue(data.planOrderList, _self.planOrderGrid);
				_self.planOrderGridTitle.show();
			}
			if(data.manuOrder) {
				_self.setValue(data.manuOrder, _self.manuOrderForm);
			}
			if(data.manuOrderList) {
				_self.setGridValue(data.manuOrderList, _self.manuOrderGrid);
				_self.manuOrderGridTitle.show();
			}
			//if(data.jobPlan) {
				//_self.setValue(data.jobPlan, _self.jobPlanForm);
			//}
			//if(data.jobPlanList) {
				//_self.setGridValue(data.jobPlanList, _self.jobPlanGrid);
				//_self.jobPlanGridTitle.show();
			//}
			if(data.jobOrder) {
				_self.setValue(data.jobOrder, _self.jobOrderForm);
			}
			if(data.jobOrderList) {
				_self.setGridValue(data.jobOrderList, _self.jobOrderGrid);
				_self.jobOrderGridTitle.show();
			}
			if(data.OutOrder){
				_self.setValue(data.OutOrder, _self.planOrderOutForm);
			}
		});
	},
	setValue: function(data, form){
		var itemIds = form.getField("group").itemIds;
		for(var i = 0 ; i < itemIds.length; i ++){
			var column = form.getField(itemIds[i]);
			if(column){
				if(itemIds[i] == 'jobStatus' ){
					var status = "";
					if(data[itemIds[i]]=="CREATE"){
						status="创建";
					}else if(data[itemIds[i]]=="START"){
						status="已开工";
					}else if(data[itemIds[i]]=="FINISHED"){
						status="已完工";
					}else if(data[itemIds[i]]=="OK"){
						status="已检验";
					}else if(data[itemIds[i]]=="STOP"){
						status="暂停";
					}else if(data[itemIds[i]]=="CANCEL"){
						status="已取消";
					}
					column.setValue(status);
				} else if(itemIds[i] == 'status' ){
					var status = "";
					if(data[itemIds[i]]=="CREATE"){
						status="创建";
					}else if(data[itemIds[i]]=="AUDIT"){
						status="审核";
					}else if(data[itemIds[i]]=="RELEASE"){
						status="已下达";
					}else if(data[itemIds[i]]=="ASSIGN"){
						status="已派工";
					}else if(data[itemIds[i]]=="START"){
						status="已开工";
					}else if(data[itemIds[i]]=="OK"){
						status="已完工";
					}else if(data[itemIds[i]]=="STOP"){
						status="暂停";
					}else if(data[itemIds[i]]=="CANCEL"){
						status="已取消";
					}
					column.setValue(status);
				}else if(itemIds[i] == 'manuorderStatus' ){
					var status = "";
					if(data[itemIds[i]]=="CREATE"){
						status="创建";
					}else if(data[itemIds[i]]=="REVIEWED"){
						status="已审核";
					}else if(data[itemIds[i]]=="PART_ASSIGN"){
						status="部分派工";
					}else if(data[itemIds[i]]=="ASSIGN"){
						status="派工完成";
					}else if(data[itemIds[i]]=="OK"){
						status="已完工";
					}else if(data[itemIds[i]]=="STOP"){
						status="暂停";
					}else if(data[itemIds[i]]=="PARTOUT"){
						status="部分外协";
					}else if(data[itemIds[i]]=="OUTSOURCING"){
						status="全部外协";
					}else if(data[itemIds[i]]=="CANCEL"){
						status="已取消";
					}
					column.setValue(status);
				} else {
					column.setValue(data[itemIds[i]]);
				}

				
				column.hide();
				column.show();//这只之后不显示
			}
		}
		
		form.show();
	},
	setGridValue: function(data, grid){
		grid.show();
		var rows = grid.data;
		for (var i = 0;i < rows.length;i ++) {
			grid.removeData(rows[i]);
		}
		grid.setData(data);
	}
});
